{% extends "base.html" %}
{% block title %}
    首页
{% endblock %}

{% block script %}
    <script src="/static/lib/echarts/js/echarts.min.js"></script>
    {#导入js包#}
    <script src="/static/lib/sb-admin/vendor/jquery/jquery.min.js"></script>

{% endblock %}


{% block content %}
   <!-- Page Content -->
    <div id="page-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">首页</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div id="show"></div>
                    <div class="col-lg-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                公司新闻
                                <a class="pull-right" href="./news.html">查看更多...</a>
                            </div>
                            <div class="panel-body">

                                <div class="col-lg-6"><a href="./detail_news.html">优就业简介</a></div>
                                <div class="col-lg-6 text-right">2020-05-06 16:37:39</div>

                                <div class="col-lg-6"><a href="#">新闻99</a></div>
                                <div class="col-lg-6 text-right">2020-05-06 16:37:39</div>

                                <div class="col-lg-6"><a href="#">新闻98</a></div>
                                <div class="col-lg-6 text-right">2020-05-06 16:37:39</div>

                                <div class="col-lg-6"><a href="#l">新闻97</a></div>
                                <div class="col-lg-6 text-right">2020-05-06 16:37:39</div>

                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                考勤情况
                                <a class="pull-right" href="attendance_me.html">查看更多...</a>
                            </div>
                            <div class="panel-body">

                                <div class="col-lg-6">摔伤了，请假3天。</div>
                                <div class="col-lg-6 text-right">已驳回</div>

                                <div class="col-lg-6">住院5天</div>
                                <div class="col-lg-6 text-right">已通过</div>

                                <div class="col-lg-6">因家里有事，调休1天</div>
                                <div class="col-lg-6 text-right">已驳回</div>

                                <div class="col-lg-6">请年假1天</div>
                                <div class="col-lg-6 text-right">申请中</div>

                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
        </div>
        <!-- /.container-fluid -->
    </div>
    <!-- /#page-wrapper -->
    <script>
        var myChart = echarts.init(document.getElementById('show'));
        var option = {
            title: {
                text: '公司各部门职员人数统计'
            },
            tooltip: {},
            legend: {
                //data: ['职员人数']
            },
            xAxis: {
                data: []
            },
            yAxis: {},
            series: [{
                name: '职员人数',
                type: 'bar', //柱状图
                data: []
            }]
        };
        // myChart.setOption(option);

        $.ajax({
            url:"/echarts_api",
            data:"",
            type:"get",
            success:function (data) { //请求成功
                console.log(data.data);  //打印返回值
                  // 获取数据  绑定数据
                var x = option.xAxis.data = [];
                var y = option.series[0].data = [];
                for (var one in data.data){
                    x.push(data.data[one].name);
                    y.push(data.data[one].num);
                }
                console.log(x);
                console.log(y);

                //option.series[0].data = data.data; // 数组
                myChart.setOption(option);

            },
            error:function (error) { //请求失败
                //失败的信息
                console.log(error)

            }



        })

    </script>
{% endblock %}

